<!---
Copyright: (c) 2006 The MachBlog Authors
Authors: Matt Woodward (mpwoodward@gmail.com) & Peter J. Farrell (pjf@maestropublishing.com)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at 

http://www.apache.org/licenses/LICENSE-2.0 

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and 
limitations under the License.

$Id: BlogService.cfc 899 2006-07-09 02:47:07Z mpwoodward $

Notes:
--->
<cfcomponent displayname="BlogService" output="false" hint="BlogService for MachBlog">
	<cfproperty name="blogGateway" type="org.machblog.blog.BlogGateway" required="true" />
	<cfproperty name="userFacade" type="org.machblog.facades.UserFacade" required="true" />
	
	<cffunction name="init" access="public" output="false" returntype="BlogService" 
			hint="Constructor for this CFC">
		<cfreturn this />
	</cffunction>

	<cffunction name="setBlogGateway" access="public" output="false" returntype="void" 
			hint="dependency: injected">
		<cfargument name="blogGateway" type="org.machblog.blog.BlogGateway" required="true" />
		<cfset variables.blogGateway = arguments.blogGateway />
	</cffunction>
	<cffunction name="getBlogGateway" access="public" output="false" 
			returntype="org.machblog.blog.BlogGateway">
		<cfreturn variables.blogGateway />
	</cffunction>
	
	<cffunction name="setUserFacade" access="public" output="false" returntype="void">
		<cfargument name="userFacade" type="org.machblog.facades.UserFacade" required="true" />
		<cfset variables.userFacade = arguments.userFacade />
	</cffunction>
	<cffunction name="getUserFacade" access="public" output="false" 
			returntype="org.machblog.facades.UserFacade">
		<cfreturn variables.userFacade />
	</cffunction>
	
	<cffunction name="getDaysBlogging" access="public" output="false" returntype="numeric" 
			hint="Gets the number of days a user has been blogging.  If no ID is passed in the logged-in user's id is assumed.">
		<cfreturn getBlogGateway().getDaysBlogging() />
	</cffunction>
	
	<cffunction name="getCurrentUserDaysBlogging" access="public" output="false" returntype="numeric" 
			hint="Gets the number of days the currently logged-in user has been blogging">
		<cfreturn getBlogGateway().getDaysBlogging(getUserFacade().getUser().getUserId()) />
	</cffunction>
</cfcomponent>